<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>主页</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
        }

        .welcome-box {
            text-align: center;
            padding: 20px;
            background-color: #f0f0f0;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }

        h1 {
            color: #333;
        }

        p {
            color: #666;
        }
    </style>
</head>
<body>
    <div class="welcome-box">
        <h1>欢迎，<span id="usernameSpan"></span>!</h1>
        <p>您已成功登录，这是您的主页。</p>
        <button onclick="window.location.href='login.html'">退出登录</button>
    </div>

    <script>
        // 获取当前用户信息
        const currentUser = localStorage.getItem('currentUser');
        if (!currentUser) {
            window.location.href = 'login.html';
        }

        document.getElementById('usernameSpan').textContent = currentUser;

        // 退出登录按钮点击事件
        document.querySelector('button').addEventListener('click', () => {
            localStorage.removeItem('currentUser');
            window.location.href = 'login.html';
        });
    </script>
</body>
</html>